﻿/**
 * \brief Initial game mode that will be used for testing purposes
 * This will likely be the default game mode for quite some time, 
 * so I will try to make it as flexible as possible, so if we want
 * to extend this class we can.
 * 
 * Only available offline
 */

using System;
using UnityEngine;
using KaoticSSB.Players;
using System.Collections.Generic;

namespace KaoticSSB.GameModes
{
	public class GameMode_BasicAI : GameMode
	{
		public GameMode_BasicAI() 
		{
			Name = "Vs. AI";
		}
		
		public override void Startup ()
		{
			SoundManager.GetInstance().PlayMusicOverTime("music02", 10.0f);

			mPlayerManager = GameObject.FindObjectOfType<PlayerManager>();
			Rigidbody2D playerOne = mPlayerManager.CreatePlayer(1);
			PlayerBase player = playerOne.GetComponent<Player>();
			mPlayers.Add (player);

			Rigidbody2D playerTwo = mPlayerManager.CreateBot(2);
			player = playerTwo.GetComponent<BotBase>();
			mPlayers.Add (player);
		}
		
		public override void Shutdown ()
		{
		}
		
		public override void GameModeUpdate ()
		{
			foreach(PlayerBase player in mPlayers)
			{
				if(player != null && player.Dead)
				{
					if(player.RespawnTimer <= 0.0f)
					{
						player.Respawn();
					}
				}
			}
		}
		
		public override bool ShouldShutdown ()
		{
			return mFlaggedForShutdown;
		}
		
		public override void FlagForShutdown ()
		{
			mFlaggedForShutdown = true;
		}
		
		private void RespawnPlayer(int index)
		{
		}
		
		private PlayerManager mPlayerManager;
		private List<PlayerBase> mPlayers = new List<PlayerBase>();
	}
}

